package com.Tools.TestDb.Mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.Tools.TestDb.Entity.TestDb;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface TestDbMapper extends BaseMapper<TestDb> {

    // 根据bankType随机获取指定数量的题目
    @Select("SELECT * FROM interviewqas WHERE bank_type = #{bankType} ORDER BY RAND() LIMIT #{count}")
    List<TestDb> getTestDbByBankTypeRandom(@Param("bankType") String bankType, @Param("count") int count);
    // 根据id更新题目得分、回答次数和掌握程度
    @Update("UPDATE interviewqas SET answer_count = #{answerCount}, average_score = #{averageScore}, mastery = #{mastery} WHERE id = #{id}")
    void updateTestDbScoreById(@Param("id") Long id, @Param("answerCount") int answerCount, @Param("averageScore") int averageScore, @Param("mastery") String mastery);
}